from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
from django.views.generic.date_based import archive_index
from django.views.generic.list_detail import object_detail, object_list
from django.views.generic.simple import direct_to_template
from core.models import *
from tagging.models import *
from photologue.models import *
from django.conf import settings
from photologue.models import *
from core.views import *

admin.autodiscover()

# Number of random images from the gallery to display.
SAMPLE_SIZE = ":%s" % getattr(settings, 'GALLERY_SAMPLE_SIZE', 5)


gallery_args = {
    'date_field': 'date_added',
    'allow_empty': True,
    'template_name':'list.html',
    'queryset': Gallery.objects.filter(is_public=True),
    'extra_context':{'sample_size':SAMPLE_SIZE}
    }

photo_args = {
    'date_field': 'date_added', 
    'allow_empty': True,
    'template_name':'object.html',
    'queryset': Photo.objects.filter(is_public=True)
    }

urlpatterns = patterns('',

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    #(r'^facebook/?$', include('facebookconnect.urls')),

    (r'', include('social_auth.urls')),
    

    #((r'^/?$',  direct_to_template, {'template': 'main.html', 'extra_context':{'objects':Event.objects.all()}})),
    #above commented because I decided to show news page to begin with instead

    #(r'^photologue/', include('photologue.urls')),

    (r'^admin/', include(admin.site.urls)),
    (r'^comments/', include('django.contrib.comments.urls')),
    #(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
    #    {'document_root': settings.MEDIA_ROOT}),
    

    
    url(r'^/?$', direct_to_template, {'template': 'main.html'}, name='Frontpage'),
    
    #url(r'^thoughts/', object_list, {'queryset':Thought.objects.all(), 'template_name':'archive.html'}, name='thoughts'),
    url(r'^search/?$', get_objects, name='Search'),
    url(r'^controlled/(?P<path>.*)$', xsendfile, name='Xsend'),    

    #url(r'^/?$', archive_index, {'queryset':Event.objects.filter(tags__contains='news'), 'template_name':'list.html', 'date_field':'date_time', 'allow_future':True}, name='Front'),    

    url(r'^/?$', authd_list, name='Frontpage'),   

    url(r'^journal/?$', authd_list, name='Event'),

#    url(r'^news/(?P<slug>.*)/?$', object_detail, {'queryset':Event.objects.filter(tags__contains='news'), 'template_name':'object.html','slug_field':'slug'}, name='Event'),

    url(r'whereabouts/?$', whereabouts, name='Whereabouts'),

    url(r'whoabouts/?$', whoabouts, name='Whoabouts'),

    url(r'^opinions/?$', archive_index, {'queryset':Opinion.objects.all(),'date_field':'date_time', 'template_name':'list.html'}, name='Opinions'),

    url(r'^opinions?/(?P<slug>.+)/?$', authd_detail, {'model':Opinion}, name='Opinion'),    

    url(r'^projects?/(?P<slug>.+)/?$', authd_detail, {'model':Project}, name='Project'),

    url(r'^projects?/?$', object_list, {'queryset':Project.objects.all(), 'template_name':'list2.html'}, name='Projects'),

    #galleries
    url(r'^photos/?$', object_list, {'queryset': Gallery.objects.filter(is_public=True), 'allow_empty': True, 'paginate_by': 20}, name='Photos'),

    url(r'^gallery/(?P<slug>[\-\d\w]+)/$', object_detail, {'slug_field': 'slug','template_name':'object.html', 'queryset': Gallery.objects.filter(is_public=True), 'extra_context':{'sample_size':SAMPLE_SIZE}}, name='pl-gallery'),    

    #photos
#    url(r'^photo/(?P<slug>[\-\d\w]+)/$', authd_detail, {'model':Photo}, name='pl-photo'),
    url(r'^photo/(?P<slug>[\-\d\w]+)/$', object_detail, {'slug_field': 'slug','template_name':'object.html', 'queryset': Photo.objects.filter(is_public=True)}, name='pl-photo'),
    
    url(r'^photo/page/(?P<page>[0-9]+)/$', object_list, {'queryset': Photo.objects.filter(is_public=True), 'allow_empty': True, 'paginate_by': 20}, name='pl-photo-list'),

    url(r'map/?$', map_all, name='Map')
    
    #(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
    #    {'document_root': '/home/aaron/brainontheweb/site_media', 'show_indexes': True}),


)
